<?php

/*

  Action	$5

  +1 Action
  Trash a card from your hand.  +1 Card per Coin it costs.  +2 Cards if it has potion in its cost.

 */

class Apprentice extends Card implements iAction, iKingdom, iAlchemy {

    public function __construct() {
        parent::__construct("Apprentice", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            " +1 Action",
            "Trash a card from your hand.  +1 Card per Coin it costs.  +2 Cards if it has potion in its cost.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addActions(1);

        $playHand = $game->getPlayHand();
        if (sizeof($playHand) > 0) {

            $playHand = getUniqueCards($playHand);
            if (sizeof($playHand) > 1) {
                $output = MySocket::GetUserReply($game, Input_ChooseOne, $playHand, 1, 1, null, "Choose card to trash");
                $card = n2c($output[0]);
            } else {
                $card = $playHand[0];
            }

            ScreenDisplay::addScreenMessage($game, true, "trash  " . nicePrint($card), "trashes " . ScreenDisplay::$LMSG);

            $price = $card->getPrice($game);
            $drawCardsNum = $price->getCoins();
            if ($price->getPotions() > 0) {
                $drawCardsNum += 2;
            }

            $game->moveCardFromPileToPile($card, PlayHand, Trash);
            $drawed_cards = $game->drawCards($drawCardsNum);
            ScreenDisplay::addScreenMessage($game, false, " and draw " . nicePrint($drawed_cards), " and draws " . sizeof($drawed_cards) . " cards");
        } else {
            ScreenDisplay::addScreenMessage($game, true, "trash  nothing", "trashes nothing");
        }
        $game->cardActionFinished();
        return true;
    }

}

?>